package io.mft.plugin;

import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLClassLoader;
/**
public class PluginClassLoader extends URLClassLoader{

	public PluginClassLoader(ClassLoader parent,URL... urls) {
		super(urls, parent);
	}

	@Override
	protected Class<?> findClass(String name) throws ClassNotFoundException {
		return super.findClass(name);
	}
	
	@Override
	public Class<?> loadClass(String name) throws ClassNotFoundException {
		return super.loadClass(name);
	}
	
	public void add(URL...urls) {
		for (URL url : urls) {
			addURL(url);
		}
		
	}
	@Override
	public InputStream getResourceAsStream(String name) {
		InputStream inputStream= super.getResourceAsStream(name);
		if (inputStream==null) {
			inputStream=getParent().getResourceAsStream(name);
		}
		return inputStream;
	}
	@Override
	public URL getResource(String name) {
		URL url=super.findResource(name);;
		if (url==null) {
			url=getParent().getResource(name);
		}
		return url;
	}
	
	public InputStream getSelfResourceAsStream(String name) {
		try {
			URL url=findResource(name);
			InputStream inputStream=null;
			if (url!=null) {
				inputStream=url.openStream();
			}
			return inputStream;
		} catch (IOException e) {
			return null;
		}

	}
}
**/
